You are here: Statements and Functions > Activate
Syntax samples
ACTIVATE <subroutine>({parameter1>,<parameter2>...})
ACTIVATE Sub1()
Starts an independent subroutine. The calling logic then continues without waiting for the called subroutine to finish. Therefore, independent subroutines can run in parallel with the logic that called them. Independent subroutines are not entity or location dependent and run without regard to what happens inside the logic that called them.
Use ACTIVATE to process logic that has WAIT or WAIT...UNTIL statements when you do not want to use an entity to process the WAIT or WAIT...UNTIL statements. For example, an ACTIVATE in the initialization logic could call a subroutine that adjusts the arrival frequency for a type of entity depending on the time of day.
Independent subroutines called with ACTIVATE cannot use entity-specific or location-specific system functions. If the subroutine has a return value, then that value is ignored. External subroutines cannot be called with ACTIVATE, although they may be called from within an activated subroutine.
Any logic.
Components
<subroutine>
The name of the subroutine to run. This name should appear exactly as if the subroutine were being called normally. Any return value for this function is ignored. See Subroutines.
<parameters>
The parameters that the subroutine normally takes.
Example
This example uses ACTIVATE in a model’s initialization logic to start a subroutine named Res_Log(). Res_Log() is a user-defined subroutine that logs every time that all units of a resource named Worker are in use. After it logs the time that all units were busy, it waits ten minutes to check again. Note that the WHILE...DO loop in the subroutine is never exited. This technique allows the subroutine to run during the entire simulation.
Initialization Logic:
Activate Res_Log()
Res_Log()
INT X = 1
WHILE X = 1 DO
BEGIN
IF FREEUNITS(Worker)=0
THEN LOG "All workers busy at ",0
WAIT 10
END
XSUB(). Also see Subroutines.